<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        var obj = {
            
        };
        // obj.a=10;
        var a=0;
        Object.defineProperty(obj,'a',{
            get(){
                // 获取这个属性时触发
                console.log("我获取了");
                return a;
            },
            set(val){
               
                a=val;
                console.log("我设置了")
            }
        })
        console.log(obj.a);
        obj.a=10;
        console.log(obj.a);
        /* 
       vm =  {
            a:xx,
            b:c,
            c:xx
        }
         */
    </script>
</body>
</html>